package service;

import Bean.User;
import DAO.UserDAO;
import DAO.UserDAOImpl;

/**
 * @author jianjun
 * @Describe
 * @creat 2021-12-13-15:01
 */
public class UserServiceImpl implements UserService {
    private UserDAO userDAO = new UserDAOImpl();

    @Override
    public void registUser(User user) {
        userDAO.SaveUser(user);
    }

    @Override
    public User login(User user) {
        return userDAO.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        if (userDAO.queryUserByUsername(username) == null) {
            return false;
        } else {
            return true;
        }
    }
}
